Repository navigation
Reimplement UpdateArabianArcher and UpdateCrusaderArcher from gynt's units branch, under /GL (100%) - #518
Merged
Conversation
Units::UpdateArabianArcher at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 8ddb499 at 47.67% and the style commit d1b0231 at 51.95%), through the forms on our development branches. The statements are his; what the text needed is how they are arranged: 1. The draft had every case from 105 on nested inside state 0's `if (isDisappearing == 0)`. The original is flat: state 0 starts with `if (isDisappearing != 0) { fade; return; }` (0x005704D3). 2. `int building = targetID_OR_targetBuildingID;` stands in front of the pitch test, which uses it (movsx ebp at 0x00570477, in front of the jne). 3. State 0's end is one if / else chain with a single return behind it: the four targeting types and acquireShootTarget: shoot; the AI arm: state 7; `dist > 400`: state 11; `dist > 432`: state 8; acquireShootTarget: shoot; else state 8. The original keeps the later copy of the shoot block (0x00570628; the first arm jumps forward into it from 0x00570599) and has two `state = 8` (the unit's offset is computed again only behind the failed acquire, 0x00570648, and joins the other at 0x00570653). 4. The move states' walk-speed block in the original's form: the delayed arm first, the sheet store in every arm, one arm per reason to stand still (the run-up, the tribe rallying, isMatchingSpeed), then `movementType_OR_targetUnitID == 0` and its else, both `sheet = 129; speed = 1` (a compare with no jump at 0x005707B5). The appear state's block in the same form. 5. Gathering at the keep: `((int)mapTimeInTicks + slot) % 40` (cdq at 0x005706A8), the state store written in front of the counter. 6. The sit-down state: four substate arms that only set the idle flag, and one `if (flag == 0) return;` behind them (0x00571610). No gameMode local: the global is read at each of its three uses (the original loads it once at 0x0057155A, between a compare and its jump). 7. The stand-up state's sprite is an if / else on the slot's parity (866 / 867). The original has no branch there (mov al, bl / not al / movsx ecx, al / and ecx, edx / or ecx, 0x362 from 0x0057147E on); written as one expression, `(~slot & 1) | 0x362` in any spelling, our compiler leaves the sign extension out. 8. The wall-attack state in the form that matched in UpdateFireThrower; the damage is `isGateOrTower ? 1 : 4` (sbb at 0x00570B5F). 9. The shoot target as an int local where the original sign-extends it once and tests the register; the aim compare is `target >= 0`, the fire compare `target > -1`. 10. Five height sums as `terrain + building`. quick_diff cannot see this (it folds every displacement); a check of the data addresses found them. 11. The fade countdown is stepped with -- on the char field (a char in main's Unit.hpp). 12. The sit-down state's tile mask is named (L_KEEP_NON_MANOR_HOUSE | L_WALL_OR_GATEHOUSE, 0x10000100). It was measured as the hex constant; with the names the compiled function text is the same, line for line. On main, this round's text pass: the BOOLEnum getKeepLocationForAIUnit, moveUnitToBehaviorTarget and isBrazierNearby tested by truthiness (two places each); the pitch test's `> 1` as PDS_READY; `(UnitState)105` and 104 as US_RALLYING and US_CLIMBING_LADDER (123 has no name yet); the `(short)` casts on `targetedBuildingTile - addXgetTile` dropped, as main's UpdateAssassin writes it; the `(char)` casts on the 15 frame-table reads dropped; `const` on the locals; the unused TargetingType include dropped; the two ternary comments without addresses; the TODO on the AttackInfo blocks dropped (main models them now); comments on the `> 432` arm that can never be true, on the walk-speed arms that store the same values, on the aim arm that stores the level aim's sprite, on the frame tested again behind the aim arms, on the fire state's `> -1` and on the owner read in the wall attack. Three edits change the listing and are not in: `owner` instead of `attacker`, one if for the aim state's two frame tests, and `>= 0` in the fire state. After the review, the walk-speed arms' comment on one line. The quick_diff listing is the same before and after. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 9f559dd (sourcehold#517 merged after them: three PathFindingState files that nothing here calls): a narrow build (459 files: main's /GL files, the two units of this branch with their callee closures, every file of a function-visibility group that touches them) and a full build of every file (2,995 files, 3,013 functions), each once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK all four. It reads 100.0 / 100.0 with the option off in both. With it on it reads 55.8 / 52.4 in both: it has no entry in cmake/function-visibility.txt, so the callees the units' wrapper holds leave the /GL list in that mode (main's UpdatePriest, a /GL unit without an entry, reads 72.0 / 68.9 there for the same reason). After the review's text fixes, a narrow build of the branch on 775527d with the option off (459 files, 469 functions, BUILD_OK) reads 100.0 / 100.0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Units::UpdateCrusaderArcher at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 07bc13f at 35.97%, 7737541 and 4bc6eb7 at 40.11%, then 6565c1b and 974c32f for the build and clang-format), through the forms on our development branches. The statements are his; what the text needed is how they are arranged. 1. State 105 (gathering at the rally point) has its counter tail once. `rallySearchOffsetsUnk[0]++; return;` was written in the RELOAD arm and again at the state's end; now the RELOAD arm and the rally test are `if (...) { state = RELOAD; } else if (isSpaceAvailableAtUnitRallyPoint(...)) { set the destination }` and both fall to the state's one tail (state 0's rally block keeps its own). The compiler merges two written copies into the same code, but each copy counts as a use of the constant 1, and with one use more that constant keeps edx through the falling state (US_DEATH_02), where the original has the ground height in edx and a 1 of its own (mov edi, 1 at 0x0055C396). That state reads as the original only with the tail written once. 2. State 0's moat arms: `targetingType = 3` is written on each of the five paths that reach it (dig: behind the countdown and in the `moat <= -1` else; fill: in both failure arms and in the else). The original computes the slot and the pointer again on each path (0x0055AA28, 0x0055AAEE, 0x0055AB6F, 0x0055AB85) and joins them at the one store (0x0055AB99). In the fill arm's first failure the reset stands in front of the countdown (the unit's offset is computed first, 0x0055AAF4). The fill arm tests `setXYBasedOnMoatID(moat, 2, ...) == 0` first. 3. The sit-down state has five flat arms (101, 106, 107, 100, else) where the draft had an outer `if (substate == 101 || ... 106 || ... 107)` around nested arms. 4. The wall attack has UpdateArabianArcher's arrangement with this unit's frame table and sprites. 5. The two moat states: the dig tile's x and y as int locals in front of xyAreValid; in the dig state, the unit on the dig tile as an int local read in front of its test (movsx ecx at 0x0055B4C6). 6. The fire state: `int heightOffset = 30;` stands in front of the target test (mov dword ptr [esp + 0x10], 0x1e at 0x0055BABD, between the compare and its jump). 7. The falling state: `direction -= 8` in place (sub eax, 8 at 0x0055C393) and the compare as `terrainOrClimbHeight > drop + groundHeight` (cmp ebx, edi at 0x0055C3F2). 8. Two conditional expressions where the original has no branch (sbb at 0x0055AF19 and 0x0055B1B7); the fade countdown without `(char)` casts (a char in main's Unit.hpp); the logic-layer masks by their LogicHelpers names. Visibility. The original does not read the slot again behind xyAreValid in the moat states, so the function needs ViewportRenderState::xyAreValid under /GL; main's /GL list has it. On main, this round's text pass: `(UnitState)105`, 104, 124 and 13 as US_RALLYING, US_CLIMBING_LADDER, US_DIG_MOAT and US_UNKNOWN_13 (123 has no name yet); the `(short)` casts on `targetedBuildingTile - addXgetTile` and on the falling state's two height stores dropped; the `(char)` casts on the 24 frame-table reads dropped; `const` on the locals; the two ternary comments and the melee state's comment on its two substate tests without addresses; the TODO on the AttackInfo blocks dropped (main models them now); comments on the `> 432` arm that can never be true, on the walk-speed arms that store the same values, on the fire state's `> -1` and on the owner read in the wall attack (with `owner` instead, the listing changes). After the review: the orientation test against CD_UNSPECIFIED, as main's UpdateEngineer and UpdatePikeman write it; comments on the dig fields read again for calculateOrientation (digX / digY there change the listing), on the two moat calls compared with 1 (a truth test changes the listing), on the fire state's three arms that read the same table (one read in front of the if changes the listing) and on the two sitting substates; the walk-speed arms' comment on one line. The quick_diff listing is the same before and after. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 9f559dd (sourcehold#517 merged after them: three PathFindingState files that nothing here calls): a narrow build (459 files: main's /GL files, the two units of this branch with their callee closures, every file of a function-visibility group that touches them) and a full build of every file (2,995 files, 3,013 functions), each once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK all four. It reads 100.0 / 100.0 with the option off in both. With it on it reads 65.7 / 61.3 in both: it has no entry in cmake/function-visibility.txt, so the callees the units' wrapper holds leave the /GL list in that mode (main's UpdatePriest, a /GL unit without an entry, reads 72.0 / 68.9 there for the same reason). After the review's text fixes, a narrow build of the branch on 775527d with the option off (459 files, 469 functions, BUILD_OK) reads 100.0 / 100.0. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 2 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 2 of the 2 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 23 — Prefer if-else over ternary
|
gynt
approved these changes
Nov 30, 2026
This was referenced Nov 30, 2026
kotijekriv
added a commit
to kotijekriv/OpenSHC
that referenced
this pull request
Nov 30, 2026
…d#515, sourcehold#516 and sourcehold#518 (sourcehold#534) sourcehold#515, sourcehold#516 and sourcehold#518 put twelve units on cmake/compiler-flags-gl.txt. UpdateCamel, UpdateLady and UpdateFireEater have an entry here already and read 100.0% with OPENSHC_FUNCTION_VISIBILITY_UNITS on; the other nine have none. In that mode the members of every group leave the /GL list, among them the helpers in the group that holds hasUnitReachedDestination, so a /GL unit without an entry no longer sees them: the nine read 37.7% to 65.7% in main ff7e56e's full build in that mode, the build the real builds below compare against. Each gets an entry at its address, its callees in address order. The /GL lines stay as they are. Each entry names only callees that are already members of the group that holds hasUnitReachedDestination, so the nine join that group and nothing else moves: no other function leaves the /GL list, and no other function sees a body it did not see before. The nine's other /GL callees (setDestinationForUnit, moveToFreeTileNearby, acquireShootTarget, shootProjectile and the rest of their closures) stay opaque to them, and they read 100.0% / 100.0% that way (raw / normalised: reccmp_report.py's normalised figure ignores call and tail-jump targets and resolver addresses). Naming each unit's whole /GL callee closure instead would put 28 more functions in that group: with every .cpp of main as the build list, cmake/function-visibility-units.py then makes 22 wrapper units holding 178 source files, against 25 holding 141 on main (the nine units and 28 of their callees join, and three smaller groups merge in). Those 28 would leave the /GL list for main's callers that have no entry (processUnitMove, exitLadder, unitClimbing, UpdateHorseArcher_DoShooting and others). Each caller-callee pair is measured as sourcehold#491's were: the unit's file compiled with the callee files pasted in front of it, against the unit alone, quick_diff on main ff7e56e. The data resolvers were switched on with tools/reimplementation-control/enable_reimplemented_data.py and the function resolver of every .cpp in the build list with tools/reimplementation-helper/batch/enable_local_functions.py (locally, not committed). The callees tried are the group's members that the unit calls directly or through another member it calls (so indirect ones too: commitUnitLocation's two callees for UpdateTunneler, ConsiderHavingABreakNowUnk behind UpdateWorker_ConsiderTakingABreakUnk for UpdateWheatFarmer), not callees reached only through functions outside the group. A callee is listed when leaving it out of that set lowers the ratio; the listed set reads what the whole set reads. quick_diff is stricter than reccmp about register names; the real builds read each unit at 100.0%. - UpdateMother: 0.5668 alone, 0.9918 with its 3. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.7900, hasUnitReachedDestination 0.8918, changeDestinationByAmount 0.8994. - UpdateChild: 0.5564 alone, 0.9993 with its 4. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.8294, hasUnitReachedDestination 0.9153, hasTunnelerNotFinishedDigging 0.9881, changeDestinationByAmount 0.9976. - UpdateTunneler: 0.6433 alone, 0.9897 with its 2. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.7619, hasUnitReachedDestination 0.6726. commitUnitLocation and its callees setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs change nothing. - UpdateWheatFarmer: 0.4115 alone, 0.9988 with its 8. Left out, IncrementAndOptionalUpdateAVValueRelated reads 0.7775, ConsiderHavingABreakNowUnk 0.9838, SetStateToFreetimeWalking 0.9898, ComputeGoodsProduced 0.9784, checkIfCitizenUnitIsAliveBasedOnState 0.8193, hasUnitReachedDestination 0.9462, changeDestinationByAmount 0.9130, UpdateWorker_ConsiderTakingABreakUnk 0.9838. - UpdateCrusaderArcher: 0.6723 alone, 0.9869 with its 3. Left out, xyAreValid reads 0.9709, hasUnitReachedDestination 0.7176, changeDestinationByAmount 0.9853. - UpdateCrossbowman: 0.6537 alone, 0.9964 with hasUnitReachedDestination. - UpdateLadderman: 0.4106 alone, 0.9938 with hasUnitReachedDestination. - UpdateArabianArcher: 0.5843 alone, 0.9944 with hasUnitReachedDestination. - UpdateFireThrower: 0.6844 alone, 0.9965 with hasUnitReachedDestination. makeUnitStopWalkingByClearingPathProgressState, which UpdateMother, UpdateChild and UpdateWheatFarmer call, changes nothing for any of them. With every .cpp of main as the build list, cmake/function-visibility-units.py now makes 25 wrapper units holding 150 source files (141 before): the nine join the group that holds hasUnitReachedDestination, and no other file changes group. CMake reads this file only with the option on, so the default build is unchanged. Real builds of this change on main ff7e56e, BUILD_OK and 0 failures each: - full, option on: every .cpp of main with all function and data resolvers on (the 12 files that don't compile since sourcehold#509's sync left out), 3,025 files and 3,043 functions, against main ff7e56e built the same way. The nine read 100.0% / 100.0% (main: 37.7% to 65.7%); nothing else reads differently. - small, both modes: main's /GL list, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units and UpdatePriest with their callee closures, and every file of a group that touches them, 485 files and 495 functions. All twelve read 100.0% / 100.0% in both modes; UpdatePriest, which has no entry, 100.0% off and 72.0% / 68.9% on, as on main. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 1, 2026
kotijekriv
added a commit
to kotijekriv/OpenSHC
that referenced
this pull request
Dec 1, 2026
…er and UpdateSlave from gynt's units branch (100%, three with OPENSHC_FUNCTION_VISIBILITY_UNITS on) (sourcehold#537) * reimplement: SHC_3BB0A8C1_0x0053C300 100.0% Reimplemented Units::UpdateShield at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: f791380 at 49.29%, cf15f54 at 52.39%, 6565c1b, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (94.0% there, on main 1f87a13). What the match needed, against the draft: - The state it starts in is picked by an if / return pair, as in main's UpdateBatteringRam (sub / neg / sbb / and at 0x0053C382); the draft had a ternary. - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The scan for engineers tests its six conditions as six `if (...) { continue; }` statements, the counts are cleared with memset, the distances compare with the engineer first, and the tests read `> 16` and `< 1`, as the original compares. The tick test reads `^ 8` where the draft had `^ 0xfffffff8`, the same value under `& 15`. - The AI check's loop and the two blocks that send the engineer to work are loops of one over manningEngineerRef and engineerIDs[9][1]: the first is a loop in the original too (0x0053C4C3), the others make it compute the unit's offset anew (0x0053C4D9, 0x0053C744), the start of a loop the compiler unrolled. Written out with index 0 (the first as a do / while (0), as its tests break out of it), they read 0.7650, 0.9848 and 0.9913 in quick_diff, against 0.9978. - The search for the capturing owner is a for loop from 1 to 8 with a found flag, the source form that matches (the binary has no flag: the loop at 0x0053C6A7 returns at its end, 0x0053C6B4), and, the last step, it has a local of its own that is copied behind the capture, as in main's UpdateBatteringRam, where the parked text searched in the local that holds the shield's owner. With it the scan's bound stays in ebx (loaded at 0x0053C57F, compared at 0x0053C682): 0.9859 -> 0.9978 in quick_diff with the /GL callees in the unit (the one line left, 0xffff against -0x1, is the same instruction). The bound read as the global itself instead of through a local came first (0.9827 -> 0.9859). - createTribe gets the owner of units[searched], where searched is the counter the scan left behind (0x0053C70F); the draft passed the shield's own owner. The same call is in main's UpdateBatteringRam, and so is the next one: addUnitToTribe gets the tribe as unitID and the shield as tribeID (0x0053C736), with a fixme for each. compiler-flags-gl.txt gets UpdateShield.cpp only: the two callees it has to see are on main's list already (quick_diff 0.5457 without hasUnitReachedDestination, 0.8707 without deselectUnit, 0.5152 without both). On main, this round's text pass: main's name for state 108, BOOLEnum calls by truthiness, `++`, `const` on locals, the fade countdown without its cast, UpdateBatteringRam's names and comments for the scan and its if / return pair for the first state. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. It reads 100.0 / 100.0 in all of them. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0054F860 96.3% 100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on Units::UpdateHunter, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 76bb533 at 48.51%, 9f9546f at 52.15%, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (95.3% there). 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry in this branch's last commit; 96.3% in the default build, so the status line carries that number, as UpdatePitchman's does. What the match needed, against the draft: - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The states are one if / else-if chain whose arms fall out of it, where the draft had a block per state that returns; the shooting state keeps its closing return. - The shooting state has the "look for another deer, or go home" block once in the arrow part, behind a flag the arrow sets, and once behind it (0x0054FF45, 0x0054FF71). The draft had it twice in the arrow part. The flag, arrowFired, is the source form that matches: the binary has none, four tests jump to 0x0054FF45. - The early exits go the original's way round: the other hunter's uid test, "the deer is gone" and "the deer is within 20" first when chasing, the walk to the post with the failed setDestinationForUnit as the else arm. - The substate set when the hunter gets back to his post is (mapTimeInTicks & 1) + 2 with no cast (0x00550529), and the two height sums of the shot have the terrain height first. What the option is for: the original knows ten of its callees and treats two, updateBuildingSignpostCounter and getResourceCountThatCanBeDeposited, as opaque (it reads the slot again behind them). Both are on main's /GL list, so the default build sees their bodies: quick_diff reads 0.9857 with all /GL callees in the unit, 0.9991 with the ten only, where the one line left, 0xff against -0x1, is the same instruction. With the option on the two are in other wrapper units. compiler-flags-gl.txt gets UpdateHunter.cpp, as it has UpdatePitchman.cpp. On main, this round's text pass: main's names (UnitState_Hunter) for the hunter's states 0 to 11 and 106, through state.hunter (as main's UpdatePitchman and UpdateWheatFarmer do for theirs), and for the resting state (USH_RESTING_7); 108 to 111, 113 and 121 keep the shared US_ names; DNE_UNKNOWN_2 and RT_MEAT; BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, the fade step stored as -2, no `(char)` on the frame tables and the fade countdown, unused `using` lines dropped, and the local for the slot in front of commitUnitLocation dropped. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 / 100.0, with it off 96.3 / 86.9. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00553AE0 94.6% 100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on Units::UpdateAppleFarmer, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 69e0814 at 43.32%, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (94.1% there). 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry as this branch's last commit leaves it; 94.6% in the default build, so the status line carries that number, as UpdatePitchman's does. What the match needed, against the draft: - The branches of four states the original's way round, read off it one basic block at a time: going to the workplace and waiting for a tree (the call that works first), the granary walk (its failure path written out), the deposit (one local for getResourceCountThatCanBeDeposited's result). - The last steps: every access reads the unit through DAT_CurrentUnitSlotID::instance (our parked text still indexed some through the draft's `unitID` and one state through a local for the slot, across a setDestinationForUnit call, which is not a named callee and stays opaque), and the waiting state stores the slot into the orchard's workers[] before it reads the frame, as main's UpdateDairyFarmer does. In quick_diff with the group's callees in the unit 0.9899 -> 0.9984 (the one line left, 0xff against -0x1, is the same instruction). Only together: 0.9844 without the second step, 0.9891 with the state's local kept. What the option is for: the original reads the slot again behind getResourceCountThatCanBeDeposited, which is on main's /GL list, so the default build sees its body and keeps the register (quick_diff 0.9820 with it, 0.9984 without). compiler-flags-gl.txt gets UpdateAppleFarmer.cpp, as it has UpdatePitchman.cpp. On main, this round's text pass: main's names for states 108 and 121 and for DNE_UNKNOWN_2, BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, no `(char)` on the frame tables and the fade countdown, the unused `using` lines and one unused include dropped, USAF_WAITING_1 for the resting state and the farmer's own state type for the local. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 / 100.0, with it off 94.6 / 89.6. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0056E190 100.0% Reimplemented Units::UpdateJester at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 146023d at 42.00%, 93b5ce0 at 50.14%, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (94.1% there). What the match needed, against the draft: - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The states are one if / else-if chain whose arms fall out of it, where the draft had a block per state that returns, and the first death state tests "the animation is over" first. - gfxBase is declared at the function's top (with a comment): the original zeroes a register for it in the first block and keeps the owner in the frame (0x0056E1C7). - The random roll is read once into an int local and compared twice (0x0056E336). The text stores the wandering state in two arms; the original has the store once (0x0056E3AF) and so has ours, the compiler merges the two arms (one arm for both cases loses the match: quick_diff 0.9950 and 0.9894 against 0.9986). - The last steps, on this main: two locals our parked text had for the slot are gone, one around changeDestinationByAmount in the walk-up state and one in front of commitUnitLocation in the fade state. With the callees' bodies visible they cost (quick_diff with the /GL callees in the unit 0.9612 -> 0.9936 -> 0.9958). And the walk-up state tests `movementSpeed < 1`, a compare with the constant 1 the original holds in bp, where the draft had `<= 0`, the same values (0.9958 -> 0.9986; the one line left, 0xff against -0x1, is the same instruction). compiler-flags-gl.txt gets UpdateJester.cpp only: the eight callees it has to see are on main's list already (quick_diff without each: checkIfCitizenUnitIsAliveBasedOnState 0.8217, changeDestinationByAmount 0.8870, hasUnitReachedDestination 0.9627, makeUnitStopWalkingByClearingPathProgressState 0.9859, hasTunnelerNotFinishedDigging 0.9944, commitUnitLocation, setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs 0.9958 each; 0.5465 without any). On main, this round's text pass: main's names for states 2, 3 and 108, BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, decimal constants, the fade step stored as -2, no `(char)` on the frame tables and the fade countdown and no `(byte)` on the random number, unused `using` lines and one unused include dropped. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. It reads 100.0 / 100.0 in all of them. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00571C00 91.7% 100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on Units::UpdateSlave, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 1f2f3bf at 43.44%, cfa098f at 49.88%, 6565c1b, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (87.4% there). 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry as this branch's last commit leaves it; 91.7% in the default build, so the status line carries that number, as UpdatePitchman's does. What the match needed, against the draft: - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The fill-moat branch counts the moat's countdown down first, then sets the targeting type, on every path (in the source, the path where setXYBasedOnMoatID returns 0 has the two the other way round, as main's UpdateEngineer does; the other order loses the match, quick_diff 0.9710 against 0.9792). The moving state tests "delay running" first; its moat branch and the digging walk go the original's way round. - The last steps, on this main (quick_diff with the group's callees in the unit, each on the one before): - the parked text's local for the slot across changeDestinationByAmount is gone, the dig state's two frame arms are the other way round, and the unit on the dig tile is read once into a local, as in main's UpdatePikeman (0.9555 -> 0.9654); - state 0 ends in a chain of three arms whose last two store the same state, as in main's UpdateEngineer: the original branches on 400 only (0x00571EFD), a two-way if / else and an early return for the 400 arm become a setcc instead (0.9683), and 0.9654 -> 0.9764 for the chain on the earlier text. The 96 of the middle arm is UpdateEngineer's number, by analogy; the original has no 96 here. - the moat's owner is read through a local for returnOwnedMoatAtTile's result (0.9764 -> 0.9792). What is left of the 0.9792 is how quick_diff spells constants, two-global sums and the timeGetTime import. - `(int)` on the tick sum in front of `% 40`: the original divides signed (cdq, idiv), as in main's UpdatePikeman; the draft's remainder is unsigned, which differs once the sum passes 2^31. What the option is for: getBuildingFlammabilityFactor is on main's /GL list, so the default build sees its body, and the original treats it as opaque (quick_diff 0.9284 with it, 0.9792 without). compiler-flags-gl.txt gets UpdateSlave.cpp, as it has UpdatePitchman.cpp. On main, this round's text pass: main's names for states 2, 104, 105, 108 and 124 and for CD_UNSPECIFIED and L_MOAT, BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, no `(char)` on the frame tables and the fade countdown and no `(short)` where main's UpdatePikeman has none, the string's text above its pointer, one unused include dropped, CD_SOUTH for the rally's facing, an else-if and one else less around the two returns. The quick_diff listing is the same before and after it. The compares with -1 (0.9693 with >= 0), the two closing stores of the dig state written on both paths (0.9622 when written once), and the US_APPEAR stores of the sheet offset and the speed in both arms (0.9759 to 0.9782 hoisted) are measured, with comments in the text. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 / 100.0, with it off 91.7 / 66.3. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * cmake: function-visibility.txt entries for UpdateShield, UpdateHunter, UpdateAppleFarmer, UpdateJester and UpdateSlave New entries for UpdateShield, UpdateHunter and UpdateJester; UpdateAppleFarmer's and UpdateSlave's, which main had before the files existed, each name two more callees. All name only callees that are already members of the group that holds hasUnitReachedDestination, so the five units join that group's wrapper unit and nothing else moves: no other function sees a body it didn't see before or loses one. Each caller-callee pair is measured as sourcehold#491's were (quick_diff, the unit's file with the callee files pasted in front of it, against the unit alone). The callees tried are the group's members that the unit calls directly or through another member it calls; one is named when leaving it out lowers the ratio, and the named set reads what the whole set reads: - UpdateShield 0.5152 alone, 0.9978 with its two: without hasUnitReachedDestination 0.5457, deselectUnit 0.8707. - UpdateHunter 0.4887 alone, 0.9991 with its ten: without IncrementAndOptionalUpdateAVValueRelated 0.6953, checkIfCitizenUnitIsAliveBasedOnState 0.9004, hasUnitReachedDestination 0.9201, ComputeGoodsProduced 0.9840, SetStateToFreetimeWalking 0.9880, UpdateWorker_ConsiderTakingABreakUnk and ConsiderHavingABreakNowUnk 0.9907 each, commitUnitLocation, setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs 0.9929 each. Not named: makeUnitStopWalkingByClearingPathProgressState (no change). - UpdateAppleFarmer 0.5793 alone, 0.9984 with its seven: without checkIfCitizenUnitIsAliveBasedOnState 0.8558, IncrementAndOptionalUpdateAVValueRelated 0.8580, ComputeGoodsProduced 0.8918, hasUnitReachedDestination 0.9408, SetStateToFreetimeWalking 0.9891; new in the entry, UpdateWorker_ConsiderTakingABreakUnk and ConsiderHavingABreakNowUnk, 0.9713 each. Not named: makeUnitStopWalkingByClearingPathProgressState (no change). - UpdateJester 0.5465 alone, 0.9986 with its eight: the numbers are in its commit. - UpdateSlave 0.5410 alone, 0.9792 with its three: without hasUnitReachedDestination 0.5245; new in the entry, xyAreValid 0.9173 and changeDestinationByAmount 0.9764. On top of the named callees, each /GL callee outside the group that the unit calls was tried one at a time, without its own callees: only updateBuildingSignpostCounter (UpdateHunter 0.9933), getResourceCountThatCanBeDeposited (UpdateHunter 0.9915, UpdateAppleFarmer 0.9820) and getBuildingFlammabilityFactor (UpdateSlave 0.9284) change a ratio, and all lower it. Full build of every file with the option on (3,041 files, 3,059 functions, BUILD_OK, 0 failures), against main 830fbd5's tree built the same way (3,036 files, 3,054 functions): nothing on main reads differently, and the five units read 100.0 / 100.0. It was made before the last text edits of the five units; quick_diff gives the same listing of every file before and after them. The generator makes 25 wrapper units holding 160 source files (155 on main): the five units join the group that holds hasUnitReachedDestination, and no other file changes group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
gynt
pushed a commit
to gynt/OpenSHC
that referenced
this pull request
Dec 2, 2026
…t and UpdateMiller (sourcehold#535) sourcehold#534 gave the nine /GL units of sourcehold#515, sourcehold#516 and sourcehold#518 that had no entry in cmake/function-visibility.txt one, and left three for a follow-up: UpdatePeasant and UpdateMiller (sourcehold#533), and UpdatePriest, main's own unit. This adds the three, each at its address, its callees in address order. All three are on cmake/compiler-flags-gl.txt already (UpdatePriest was there before those PRs); that file stays as it is. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, the members of every group leave the /GL list, among them the helpers in the group that holds hasUnitReachedDestination, so a /GL unit without an entry no longer sees them: in main e62246a's full build in that mode, the build the real builds below compare against, UpdatePriest reads 72.0% / 68.9%, UpdatePeasant 49.3% / 48.7% and UpdateMiller 51.7% / 46.2% (raw / normalised: reccmp_report.py's normalised figure ignores call and tail-jump targets and resolver addresses). UpdatePriest's entry names only callees that are already members of the group that holds hasUnitReachedDestination, as sourcehold#534's do. UpdatePeasant's and UpdateMiller's name members of that group and, each, one more /GL callee that is not in it: getDestination2EqualsGivenCoordinates for UpdatePeasant and standUpIfSeated for UpdateMiller. With the members alone they read 96.0% / 87.1% and 96.5% / 93.0% in an earlier full build of this branch with the option on (below). With that callee they read 100.0%, so it joins the group, and with the option on, CMake takes five more files off the /GL list: the three units, getDestination2EqualsGivenCoordinates and standUpIfSeated. Nothing else moves: getDestination2EqualsGivenCoordinates is called by UpdatePeasant only, and standUpIfSeated by UpdateMiller, standUpAllTribeUnits and updatePeasantSeatingAtBuilding (neither of the last two is on the /GL list or has an entry, so neither saw its body before or sees it now). No other function sees a body it did not see before. The three units' other /GL callees (setDestinationForUnit, resetUnitMovementState, clearHiddenFlagAndUpdatePosition, setWorkplaceBuildingEntryAsTarget, selectNewBlessingTarget, setUnitFacingDirectionTowardsTarget and the rest of their closures) stay opaque to them. Each caller-callee pair is measured as sourcehold#491's and sourcehold#534's were: the unit's file compiled with the callee files pasted in front of it, against the unit alone, quick_diff on main e62246a, with the data resolvers switched on by tools/reimplementation-control/enable_reimplemented_data.py and the function resolver of every .cpp in the build list by tools/reimplementation-helper/batch/enable_local_functions.py (locally, not committed). The callees tried are the group's members that the unit calls directly or through another member it calls (commitUnitLocation's callee setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs, included), not callees reached only through functions outside the group; and, for UpdatePeasant and UpdateMiller, each /GL callee outside the group that they call, one at a time on top of the named members, pasted without its own callees unless it says "with its callees". A callee is listed when leaving it out of the set lowers the ratio; the listed set reads what the whole set reads. quick_diff is stricter than reccmp about register names; the real builds read the units at 100.0%. - UpdatePriest: 0.7534 alone, 0.9986 with its 5. Left out, makeUnitStopWalkingByClearingPathProgressState reads 0.9891, IncrementAndOptionalUpdateAVValueRelated 0.8859, checkIfCitizenUnitIsAliveBasedOnState 0.9510, hasUnitReachedDestination 0.9680, changeDestinationByAmount 0.9850. commitUnitLocation, its callee setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs change nothing. - UpdatePeasant: 0.5329 alone, 0.9941 with its 3. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.5880, getDestination2EqualsGivenCoordinates 0.9725, hasUnitReachedDestination 0.9684. Outside the group, on top of the two members, clearHiddenFlagAndUpdatePosition (with its callees) and setDestinationForUnit change nothing. - UpdateMiller: 0.5531 alone, 0.9973 with its 13. Left out, getBuildingResourceAmountByUid reads 0.9722, setupUnitSharingTileIDs 0.9947, standUpIfSeated 0.9913, sitDownIfStanding 0.9953, IncrementAndOptionalUpdateAVValueRelated 0.8442, ConsiderHavingABreakNowUnk 0.9914, SetStateToFreetimeWalking 0.9707, ComputeGoodsProduced 0.9661, checkIfCitizenUnitIsAliveBasedOnState 0.8008, hasUnitReachedDestination 0.9593, setupUnitSharingCurrentTilePosition 0.9947, UpdateWorker_ConsiderTakingABreakUnk 0.9914, commitUnitLocation 0.9947. makeUnitStopWalkingByClearingPathProgressState changes nothing. Outside the group, on top of the twelve members, resetUnitMovementState (with its callees), setDestinationForUnit, setWorkplaceBuildingEntryAsTarget, addResourceToStockpile, buildingIsAccessible, updateBuildingSignpostCounter and getStorageBuildingForResourceTypeAndAmount change nothing; the last four are members of other groups, so with the option on they are off the /GL list already, and naming one would merge two groups. With every .cpp of main as the build list, cmake/function-visibility-units.py makes 25 wrapper units holding 155 source files (150 before): the three units and the two callees join the group that holds hasUnitReachedDestination, and no other file changes group. CMake reads this file only with the option on, so the default build is unchanged. Real builds on main e62246a, BUILD_OK and 0 failures each: - full, option on: every .cpp of main with all function and data resolvers on (the 3 files that don't compile there left out: findBestAttackTileByPathCost, resetTileAndClearMoat, TransformAndRenderPercentage), 3,036 files and 3,054 functions, against main e62246a built the same way. Two full builds of the branch's side: one with the three entries without getDestination2EqualsGivenCoordinates and standUpIfSeated (UpdatePriest's as it is now), which reads UpdatePeasant 96.0% / 87.1%, UpdateMiller 96.5% / 93.0% and UpdatePriest 100.0% / 100.0%; and this change, which reads the three 100.0% / 100.0%. Against main nothing else reads differently in either. - small, both modes: main's /GL list, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units of sourcehold#515, sourcehold#516 and sourcehold#518 (nine in sourcehold#534, three with an entry before it) and these three with their callee closures, standUpAllTribeUnits and updatePeasantSeatingAtBuilding, and every file of a group that touches them, 494 files and 504 functions. All fifteen units read 100.0% / 100.0% in both modes. UpdateFireBallistaBuilding: with the option off, where this file is not read, 100.0% / 100.0% with the 494 files and 99.6% / 95.5% with 492 (without standUpAllTribeUnits and updatePeasantSeatingAtBuilding), so its reading changes with the set of files built; with the option on, 99.6% / 95.5% with the 494 files, and main was not built with those files and the option on, so that case is not settled. It reads 100.0% / 100.0% in both full builds, this change's and main's. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two more Map::Units update functions, from gynt's units branch
reimpl/map-units-updatefunctions(his draft #204). We had them at 100% on our development branches on top of #378 before it merged; these are the same statements on main 775527d (which now has #516's six units), after one text pass (BOOLEnum calls tested by truthiness, enum names for state numbers and for the orientation test (CD_UNSPECIFIED), casts that change nothing dropped,conston locals, comments without addresses; each commit lists its own). Each reads 100.0% in the default build with its own line incmake/compiler-flags-gl.txt. Each commit cites gynt's commits on the file and our steps on it, and credits him as co-author. UpdateCrusaderArcher's text work began on another of our development branches, written with Claude Fable 5.2; its commit keeps that co-author line. No header change and no change tocmake/function-visibility.txt.Units::UpdateArabianArcher/GL; 55.8% withOPENSHC_FUNCTION_VISIBILITY_UNITSonUnits::UpdateCrusaderArcher/GL; 65.7% with the option onMeasured.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp (a86aceb03) with--resolve-wrapped-calls --ignore-security-cookie..cppof this branch on main 9f559dd (main plus the two files), all function and data resolvers on, built once with the option off and once with it on, 0 failures, 2,995 files and 3,013 functions each. As main's side we took round 8's full builds of Reimplement UpdateChild, UpdateWheatFarmer, UpdateCrossbowman, UpdateLadderman, UpdateTunneler and UpdateFireThrower from gynt's units branch, under /GL (100%) #516's branch, made the same way (3,011 functions): main 9f559dd is that branch with text-only edits whosequick_difflistings are the same.UI::Menu::handleMenuItems(97.9%) andConstructor_Menu(98.4%) read the same in both builds: reccmp names the constants 0x11000000 and 0x21000000 after whatever of ours lands at that address, so they flip with the image layout, as in Reimplement UpdateChild, UpdateWheatFarmer, UpdateCrossbowman, UpdateLadderman, UpdateTunneler and UpdateFireThrower from gynt's units branch, under /GL (100%) #516's builds./GLlines, their callees, every/GLfile of main and every file of a function-visibility group that touches them: 459 files, 469 functions, 0 failures in both modes. Both read 100.0% / 100.0% (normalised) with the option off; with it on they read as in the full build, and main's UpdatePriest reads 72.0% / 68.9% there as in main's own builds.quick_diffgives the same listing for each file before and after. Four edits we tried changed it and are not in:ownerinstead of the wall attack'sattacker(both files), one if for UpdateArabianArcher's two frame tests in its aim state, and>= 0for its fire state's> -1. The code they were about has a one-line comment instead.CD_UNSPECIFIEDfor UpdateCrusaderArcher's two orientation tests, as main's UpdateEngineer and UpdatePikeman write them, and one-line comments).quick_diffgives the same listing for each file before and after. Three edits changed it and are not in:digX/digYfor the twocalculateOrientationcalls, one read of the fire table in front of the fire state's three arms, and truth tests for the two moat calls; the code they were about has a comment instead. A small build of the fixed branch on 775527d with the option off (459 files, 469 functions, 0 failures) reads both at 100.0% / 100.0%.style_lint.py) and the status lines: nothing to fix automatically, no errors and 102 notes, all of the kinds below.With
OPENSHC_FUNCTION_VISIBILITY_UNITSonNeither has an entry in
cmake/function-visibility.txt. In that mode the callees the units' wrapper holds leave the/GLlist, so these units can't see them and read lower: UpdateArabianArcher 55.8% / 52.4%, UpdateCrusaderArcher 65.7% / 61.3%. Main's UpdatePriest, a/GLunit without an entry too, does the same in main's full builds (100.0% off, 72.0% / 68.9% on), as do #516's six units. Entries that name each unit's whole/GLcallee closure are left for a follow-up, with their own full build in that mode.Kept as they are
sbb); an if / else gives a branch. Each has a one-line comment on the line above its?; the style-lint bot will still list the two whose?line also holds a::.damageand the fire state'stargetZin both files (set in each arm that follows).attackerin both wall attacks reads the unit's owner again whereowneralready holds it, because the original loads it again there (withowner,quick_diffgives another listing; main's UpdateArabianSwordsman and UpdateAssassin keep the same local).buildingis read fromtargetID_OR_targetBuildingIDin front of the pitch test, as the original does, and set again from the tile in the wall attack. UpdateCrusaderArcher's twocalculateOrientationcalls read the dig fields from the unit again althoughdigX/digYhold them, with main's UpdateEngineer comment: the original reads them again there (with the locals,quick_diffgives another listing).(char)onengineerManningSiegeStateRef_checkType(twice in each file): the field holds the fade step that is added to thecharfade countdown, so the tests read it signed. It is abytein the header (as in Reimplement UpdateCamel, UpdateLady, UpdateMother and UpdateFireEater from gynt's units branch, under /GL (100%) #515 and Reimplement UpdateChild, UpdateWheatFarmer, UpdateCrossbowman, UpdateLadderman, UpdateTunneler and UpdateFireThrower from gynt's units branch, under /GL (100%) #516).(int)onmapTimeInTicks + slotin both rally states:mapTimeInTicksis unsigned, and the cast makes the% 40signed, as the original computes it.(short)stores: the match-time store(short)mapTimeInTicks, as main's unit functions write it, and UpdateCrusaderArcher's four dig-tile stores from theundefined4ALG_MoatXResult/ALG_MoatYResult, as main's UpdateEngineer writes them (header follow-up below).(UnitState)123in both files, and the projectiles(EntityType)24, 91, 92 and 93: main's enums have no value for them (header follow-ups below).advanceMoatDigProgress(...) == 1andremoveMoat(...) != 1in UpdateCrusaderArcher: both are declaredBOOLEnum, and the original compares their result with 1; each has main's UpdatePikeman comment (with a truth test,quick_diffgives another listing).boolfields tested by truthiness, other fields compared with 0:animationCycleNumberHasJustIncremented,IsGateOrTowerArray,isMatchingSpeedandfield_0x40eby truthiness; theshortcounters and flags (isDisappearingUnk,goToRallyPoint,movementRunUpTime,moveInstructionSpeedDelayTracker,isSelected,seated,killedFlagUnk) and theundefined4DAT_UnitHasBecomeIdlecompared with 0, as main does. The checker sees files doing both.field_0x58 = 0/= 1: the checker's BOOLEnum hint comes from another struct'sfield_0x58(SoundEffectsHelperData1);Unit::field_0x58is ashort, and main's UpdateHopsFarmer stores 1 and 0 into it too.quick_diffgives another listing): UpdateArabianArcher's aim state testsanimationFrame > 0twice in a row, and both fire states comparetarget > -1where the aim states havetarget >= 0. UpdateCrusaderArcher's melee state testssubstate == 0 || substate != 1, the first covered by the second; the original makes both tests.> 432arm behind the> 400test in both state 0s can never be true, and the original tests it anyway; in both move states the run-up, rallying and matching-speed arms store the same two values, and so do the last two arms; UpdateArabianArcher's aim arm forjugglerCount == -1stores the level aim's sprite; UpdateCrusaderArcher's fire state reads the same table in all threejugglerCountarms, and only the sprite differs (one read in front of the if gives another listing).field_0x14tofield_0x1df8are listed under "Names on main these files show"; for the rest (field_0x430,field_0x2ac,field_0x58) we have nothing better yet.Differences from the draft
None that reads a test the other way. We compared every test against a number in both files with gynt's drafts. Where ours is written the other way round, it means the same:
<= 70as> 70with the arms swapped (both walk-speed blocks of each file),unknownDigMoatOrWallAttackFlag1015 != 0x3f7as== 1015with the arms swapped, UpdateArabianArcher's fire testtarget < 0astarget > -1with the arms swapped, and UpdateCrusaderArcher'shandleUnitMovementWhenTargetingBuildings(...) <= 0return as a> 0block. The other extra== 0/!= 0tests of the drafts are BOOLEnum calls, now tested by truthiness, and the sit-down states' nested substate tests, now five flat arms.Header follow-ups
Each of these is a header that functions on main use, so it goes in a PR of its own, with full builds of main's users in both modes (#515 and #516 leave them the same way):
DAT_UnitHasBecomeIdleholds only 0 and 1: as aBOOLEnum, every use in these files would storeTRUE/FALSEand test by truthiness.Unit::engineerManningSiegeStateRef_checkTypeholds a signed fade step: as achar, the four(char)casts here go.UnitStatehas no value 123 (US_UNKNOWN_123), andEntityTypenone for the archers' projectiles 24 (an arrow shot at the ground), 91 (a fire arrow at a unit), 92 (a fire arrow at the ground) and 93 (a fire arrow at a pitch ditch).TileMapState::ALG_MoatXResultandALG_MoatYResultareundefined4: asint, the four(short)stores read as plain narrowing stores (main's UpdateEngineer has the same casts).Unit::field_0x2c4holds aUnitState(both files compare it with 123 before they store state 123);Unit::field_0x3f8is a 0 / 1 flag, set when an idle state first sees an attack order and cleared after each shot;Unit::field_0x40d(bool) is set when the arrow was lit at a brazier;Unit::field_0x40e(bool) asks the fire state to shoot now, and the fire state clears it.Names on main these files show (follow-ups, not changed here)
PlayerData::rallySearchOffsetsUnkis the per-group rally search offset thatgetKeepLocationForAIUnitandisSpaceAvailableAtUnitRallyPointread; it is declared 6 long, but the groups go further: UpdateArabianArcher'scountArabianArchersRelated(0x2A28) is its element 10 (the archers' group in theirgetKeepLocationForAIUnit(owner, 10, ...)), as UpdateFireThrower'scountFireThrowers(0x2A3C) is element 15.fixme_integerArrayArabianArcher1,2,3and5(UnitPropertiesDefinedData) arecharframe tables, not integer arrays: the Arabian archer's reload, aim, fire and cheering frames.UpdateCrusaderArcher's frame tables (UnitPropertiesDefinedData), by the state that reads each; renaming them is a header change, so they stay as they are here:
field_0xbf4field_0xc1c/field_0xc34/field_0xc54jugglerCount0 / 1 / -1field_0xc74field_0xe74field_0xca0/field_0xce0field_0xd18field_0xd40/field_0xd7cfield_0xf84/field_0xfc8field_0x1dd0field_0x1df8field_0x14unknownDigMoatOrWallAttackFlag1015holds 1015 when the unit was sent to fill a moat (both move states then go toUS_DIG).Other PRs
cmake/compiler-flags-gl.txt; another PR that does the same gets a one-line conflict there: keep all the lines.renderDebugDataCurrentPlayerData,applyGateOrDrawbridgeOpenCloseChange,initializeGatePathfindingForOwner,updatePathLinkageTileMap,UpdateGateHouseLarge,UpdateGateHouseSmall,UpdateWoodGate1,findBestAttackTileByPathCost,resetTileAndClearMoat,GateOpenOrClose,ClickOpenOrCloseGate,TransformAndRenderPercentage). All the builds above left them out, with their resolvers off. This PR doesn't touch them.🤖 Generated with Claude Code